Skip to content

Conversation

erikhfj
Copy link
Member

@erikhfj erikhfj commented Oct 22, 2026

Closes #17

Stacked PR

This targets feat/18-baerekraft-green-web (#59) because both change client/src/global.css. Review and merge #59 first, then this can be retargeted to main.

Summary

  • axe-core as a client dev dependency, run over the search page in all four of its states: idle, with results, with no results, and when the search fails.
  • Asserts the skip link stays the first focusable element after a search has rendered.

What was already conforming

I audited these by hand rather than assuming, and they needed no change:

  • Focus rings. There is exactly one outline declaration in the whole client, the :focus-visible rule in global.css. Nothing suppresses it anywhere.
  • Labelled controls. SearchForm's input has a visually hidden <label htmlFor>; the three buttons are "Search", "Retry search" and "Clear search" with visible text. No unlabelled control exists.
  • Result count. ResultsLayout already has role="status" with aria-live="polite", and the results region carries aria-busy.
  • Reduced motion. prefers-reduced-motion was already in global.css.

The skip link

The link is <a href="#main"> and main is a landmark with tabIndex={-1}, so it takes focus. #17 asked for a skip link "to the results" and the test asserts #main.

#main is right and I have left it. The requirement in universal utforming is that a keyboard user can bypass the repeated navigation block, and #main does exactly that. Retargeting at the results region would also skip the search form, which is a live control someone may well want to reach. So #main is the more useful target, not merely an acceptable one.

Two deliberate details in the axe harness

  • color-contrast is disabled. jsdom does no layout or painting, so axe has nothing to measure a rendered ratio against and would report every pair as incomplete rather than passing. Contrast is verified by hand in a browser and the ratios are in feat: #18 dark theme and measured bærekraft numbers #59.
  • The harness asserts axe found passing rules before asserting it found no violations. Without that an empty container passes vacuously whatever the markup looks like. I checked this by running the harness against a deliberately broken tree and confirming it reported violations.

Not covered here

Verification

  • pnpm format:check, pnpm lint, pnpm typecheck, pnpm test (53 client, 21 server)
  • axe reports zero violations on the search page in all four states

Adds axe-core as a client dev dependency and checks the search page in all
four of its states: idle, with results, with no results, and when the search
fails. Also asserts the skip link stays the first focusable element after a
search has rendered.

Two deliberate details in the harness:

- color-contrast is disabled because jsdom does no layout or painting, so axe
  has nothing to measure a rendered ratio against and would report every pair
  as incomplete rather than passing. Contrast is verified by hand in a
  browser, which is where the README numbers come from.
- the harness asserts axe found passing rules before asserting it found no
  violations. Without that an empty container would pass vacuously whatever
  the markup looked like. I checked this by running the harness against a
  deliberately broken tree and confirming it reported violations.

Verified: axe reports zero violations on the search page in all four states.
Audited by hand and already conforming: focus-visible outlines are never
suppressed anywhere in the CSS, every form control has an accessible name, and
the result count already carries role=status with aria-live=polite.
@erikhfj erikhfj requested a review from a team as a code owner October 22, 2026 21:56
AI usage rows for 20 and 22 October, including the review finding I got wrong
and corrected, and the one palette value the tool proposed that did not meet
the 3:1 a form-control border needs.

Three statements were out of date. architecture.md still listed URL-based
search state as planned, which landed with #19. The README still listed
accessibility and sustainability as planned while both are delivered here. The
README milestone row still said M2 was current and the frontend description
still mentioned a 300 ms debounce that #19 removed.
@erikhfj erikhfj changed the base branch from feat/18-baerekraft-green-web to main October 23, 2026 17:06
Rachel was right that the old assertion proved nothing about keyboard use. It
checked that the first element matching a focusable selector carried the
skip-link class, which passes even when the link is unreachable or points at
nothing.

Replaced with two tests that say what they mean. One Tab from a fresh page must
land on the skip link, and the href must resolve to an element that can take
focus. That needs @testing-library/user-event, since jsdom does not traverse
the tab order on its own.

Checked the tests fail when they should: with the link given tabIndex=-1 and
href=#nope both go red. The old test passed against that same broken markup.
@erikhfj
Copy link
Member Author

erikhfj commented Oct 23, 2026

Both done - thanks for the nudge on the retarget, and you were right about the test.

Retargeted

#60 now targets main since #59 is in. The diff is down to the a11y work only.

The skip-link test

Your read was exact. The old assertion checked that the first element matching a[href], button, input, [tabindex] carried the skip-link class. That is DOM order and nothing else - it passes against a link that Tab can never reach, and against one pointing at an id that does not exist.

Replaced with two tests that each claim one thing:

  1. One Tab from a fresh page lands on the skip link. This needs @testing-library/user-event, because jsdom does not walk the tab order on its own; the new dev dependency is that.
  2. The href resolves to an element that can take focus. Not just that it exists - tabIndex={-1} on the target matters, otherwise the browser scrolls there and leaves focus stranded in the navigation.

I checked the tests fail when they should rather than trusting a green suite. Gave the link tabIndex={-1} and href="#nope" and both went red:

× is the first thing Tab reaches on the search page
× points the skip link at a target that exists and can take focus
  AssertionError: expected null not to be null

The old test passed against that same broken markup, which is the gap you spotted.

Full gate suite green: 54 client, 21 server.

@erikhfj erikhfj requested a review from rachelks October 23, 2026 17:12
Copy link
Member

@rachelks rachelks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now! The updated tests address my previous comment. Thanks for fixing this! 😊

@rachelks rachelks merged commit 40c38df into main Oct 23, 2026
2 checks passed
@rachelks rachelks deleted the feat/17-accessibility-pass branch October 29, 2026 15:37
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Accessibility pass (universal utforming)
2 participants